#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int cmp(const void* p1, const void* p2)
{
	return (*(int*)p1 - *(int*)p2);
}
void swap(char* p1, char* p2, int  sz)
{
	for (int i = 0; i < sz; i++)
	{
		char tmp = *(p1 + i);
		*(p2 + i) = *(p1 + i);
		*(p1 + i) = tmp;
	}
}
void _bubble(void* base, size_t count, size_t sz, int(*cmp)(void*, void*))
{
	int i = 0;
	int j = 0;
	for (i = 0; i < count - 1; i++)
	{
		for (j = 0; j < count - i - 1; j++)
		{
			if (cmp((char*)base + j * sz, (char*)base + (j + 1) * sz) > 0)
				swap((char*)base + j * sz, (char*)base + (j + 1) * sz, sz);
		}
	}
}
int main()
{
	int arr[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };
	int i = 0;
	_bubble(arr, sizeof(arr) / sizeof(arr[0]), sizeof(int), cmp);
	for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");

	return 0;
}







